# class Parent:  # 定义父类
#     def myMethod(self):
#         print('调用父类方法')
#
# class Child(Parent):  # 定义子类
#     def myMethod(self):
#         print('调用子类方法')
#
# c = Child()          # 子类实例
# c.myMethod()         # 子类调用重写方法
# super(Child,c).myMethod() # 用子类对象调用父类已被覆盖的方法


# class MyClass:
#     """一个简单的类实例"""
#     i = 12345
#
#     def __init__(self):
#         print("__init____init____init__")
#         self.data = []
#
#     def f(self):
#         return 'hello world'
#
# myClass = MyClass()
# print(myClass.i)
# print(myClass.f())

# class Complex:
#     def __init__(self, realpart, imagpart):
#         self.r = realpart
#         self.i = imagpart
#
# x = Complex(3.0, -4.5)
# print(x.r, x.i)   # 输出结果：3.0 -4.5
# class People:
#     # 定义基本属性
#     name = ''
#     age = 0
#     # 定义私有属性,私有属性在类外部无法直接进行访问
#     __weight = 0
#
#     # 定义构造方法
#     def __init__(self, n, a, w):
#         self.name = n
#         self.age = a
#         self.__weight = w
#
#     def speak(self):
#         print("%s 说: 我 %d 岁。" % (self.name, self.age))
#
#
# pp = People('runoob', 10, 30)
# pp.speak()
